package com.hkts.reportform.datastatics.controller;

import com.hkts.reportform.datastatics.service.ReportService;
import com.hkts.reportform.datastatics.service.WechatDataService;
import com.hkts.reportform.datastatics.serviceImpl.WechatDataServiceImpl;
import com.hkts.reportform.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassNameWechatDataController
 * @Description  微信小程序 erp数据接口
 * @Author yck
 * @Date2020-10-30 14:15
 * @Version V1.0
 **/
@RestController
@RequestMapping("/erp/wechat")
public class WechatDataController {

    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private WechatDataService wechatDataServiceImpl;
    //石油焦消耗情况
    @RequestMapping("/cusomeFindStockByCode")
    public Result<Object> cusomeFindStockByCode(String dateType,String beginDate,String endDate,String inventoryClass){
        Map<String,  Object> stringMap= wechatDataServiceImpl.cusomeFindStockByCode(dateType, beginDate, endDate, inventoryClass);
        return ResultUtil.data(stringMap);
    }
    //消耗析图 dateType week 周  month ，custom    ,inventoryClass
    @RequestMapping("/getConsumeData")
    public Result<Object> getConsumeData(String dateType,String beginDate,String endDate,String inventoryClass) throws ParseException {
        Map<String,  Object> stringMap= wechatDataServiceImpl.consumeDataUpdate(dateType, beginDate, endDate, inventoryClass);
        return ResultUtil.data(stringMap);
    }
    //现存量随时间变化趋势
    @RequestMapping("/getStockData")
    public Result<Object> getStockData(String dateType,String beginDate,String endDate,String inventoryClass) throws ParseException {
        Map<String,  Object> stringMap= wechatDataServiceImpl.getStockData(dateType, beginDate, endDate, inventoryClass);
        return ResultUtil.data(stringMap);
    }
   //实时库存
   @RequestMapping("/getReltimeStockData")
   public Result<Object> getReltimeStockData(String inventoryClass) throws Exception {
       List<Map<String,  Object>> list= wechatDataServiceImpl.getReltimeStockData( inventoryClass);
       return ResultUtil.data(list);
   }
   //生产趋势
   @RequestMapping("/getFinishedProductsDataTrend")
   public Result<Object> getFinishedProductsDataTrend(String dateType,String beginDate,String endDate,String inventoryClass) throws Exception {

       // Map<String,  Object> result= wechatDataServiceImpl.finishedProductsData(dateType,beginDate,endDate,inventoryClass);

       Map<String, Object> maps = wechatDataServiceImpl.finishedProductsData(dateType, beginDate, endDate, inventoryClass);
       return ResultUtil.data(maps);
   }
   //生产情况finishedProductsData
   @RequestMapping("/getFinishedProductsData")
   public Result<Object> getFinishedProductsData(String dateType,String beginDate,String endDate,String inventoryClass) throws Exception {

       // Map<String,  Object> result= wechatDataServiceImpl.finishedProductsData(dateType,beginDate,endDate,inventoryClass);

       Map<String, Object> maps = wechatDataServiceImpl.finishedProductsDataUpdate(dateType, beginDate, endDate, inventoryClass);
       return ResultUtil.data(maps);
   }

    //首页
    @RequestMapping("/getInventoryCusomeByCInvCode")
    public Result<Object> getInventoryCusomeByCInvCode() throws Exception {
        Map<String,  Object> result= wechatDataServiceImpl.inventoryCusomeByCInvCode();
        return ResultUtil.data(result);
    }
    //辅料出库数量按时间分组groupby sum
    @RequestMapping("/getAccessoriesSumByDate")
    public Result<Object> getAccessoriesSumByDate(String dateType,String beginDate,String endDate) throws Exception {
        Map<String,  Object> result= wechatDataServiceImpl.accessoriesSumByDate(dateType,beginDate,endDate);
        return ResultUtil.data(result);
    }

    //辅料出库数量按时间分组groupby sum
    @RequestMapping("/getAccessoriesTopTen")
    public Result<Object> getAccessoriesTopTen(String dateType,String beginDate,String endDate) throws Exception {
        List<Map<String, Object>> maps = wechatDataServiceImpl.accessoriesTopTen(dateType, beginDate, endDate);
        return ResultUtil.data(maps);
    }
    //辅料出库类别比例typesOfAccessories
    @RequestMapping("/getTypesOfAccessories")
    public Result<Object> getTypesOfAccessories(String dateType,String beginDate,String endDate) throws Exception {
        List<Map<String, Object>> maps = wechatDataServiceImpl.typesOfAccessories(dateType, beginDate, endDate);
        return ResultUtil.data(maps);
    }
    //首页生坯,熟坯生产情况
    @RequestMapping("/getIndexProduct")
    public Result<Object> getIndexProduct(String dateType,String inventoryClass) throws Exception {
        Map<String, Object> maps = wechatDataServiceImpl.getIndexProduct(dateType,inventoryClass);
        return ResultUtil.data(maps);
    }
}
